<?php

namespace oauth2server\controllers;

use common\components\Oauth2;
use Yii;
use yii\web\Controller;


class ProductController extends Controller{

    /**
     * 产品列表
     */
    public function actionList(){

        $server = Oauth2::getServer();

        if(!$server->verifyResourceRequest(\OAuth2\Request::createFromGlobals())) {
            $server->getResponse()->send();

            //die;
            exit(json_encode(["code"=>-1, "info"=>"failed!"], JSON_UNESCAPED_UNICODE));
        }


        $products = [
            ["id"=>1, "name"=>"iPhone 6"],
            ["id"=>2, "name"=>"iPhone 6s"],
            ["id"=>3, "name"=>"iPphone 7"],
            ["id"=>4, "name"=>"iPhone SE"],
            ["id"=>5, "name"=>"iPhone 8"],
        ];

        exit(json_encode($products, JSON_UNESCAPED_UNICODE));
    }


}
